﻿using System;
using System.Drawing;

namespace Spencen.Mobile.Markup.Converters
{
    public class PointConverter : Converter<Point>
    {
        public override string ConvertToString( Point input )
        {
            return string.Format( "({0},{1})", input.X, input.Y );
        }

        public override Point ConvertFromString( string input, Type toType )
        {
            var axis = input.Split( ',' );
            if ( axis.Length == 2 )
            {
                var result = new Point( int.Parse( axis[ 0 ] ), int.Parse( axis[ 1 ] ) );
                return result;
            }
            throw new ArgumentOutOfRangeException( "input" );
        }
    }
}
